package org.jtzc.springaiagent.agent.only;

import org.jtzc.springaiagent.agent.BaseAgent;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author wu chuang
 * @description
 */
@Service
public class OpenAiAgent implements BaseAgent {

    @Autowired
    private ChatClient chatClient;


    @Override
    public BaseAgent.AgentResponse execute(BaseAgent.AgentRequest request) {
        String response = chatClient.prompt().user(request.prompt()).call().content();
        return new BaseAgent.AgentResponse(response, Map.of("model", "gpt-4"));
    }
}
